package lab

// UniqWith 使用自定义比较函数来判断元素是否重复
func UniqWith[T any](array []T, fn func(T, T) bool) []T {
	var result []T
	for _, v := range array {
		duplicate := false
		for _, r := range result {
			if fn(v, r) {
				duplicate = true
				break
			}
		}
		if false == duplicate {
			result = append(result, v)
		}
	}
	return result
}
